#!/usr/bin/python
# -*- mode:python; coding:utf-8 -*-

import cv

c = cv.CreateCameraCapture(0)

cv.NamedWindow("Test 04")
cv.StartWindowThread()

cv.SetCaptureProperty(c, cv.CV_CAP_PROP_FRAME_WIDTH, 640)
cv.SetCaptureProperty(c, cv.CV_CAP_PROP_FRAME_HEIGHT, 480)

while True:
    f = cv.QueryFrame(c)
    if not f: break

    cv.ShowImage("Test 04", f)
    d = 1000 / 30
    k = cv.WaitKey(d)
    if k != -1:

        # Save snapshot
        cv.SaveImage("snapshot.png", f)
        break

